import 'package:flutter/foundation.dart';

void log(String msg) {
  if (kDebugMode) {
    final stackTrace = StackTrace.current;
    final stackFrame = stackTrace.toString().split('\n')[1]; // 第一个元素通常是当前函数
    final funcPartReg = RegExp(r' +(.*? \(.*?\))');
    final funcPart = funcPartReg.firstMatch(stackFrame)?.group(1);
    print("[$funcPart]\n    $msg\n");
  }
}
